#!/usr/bin/python
# -*- coding: utf-8 -*-
from sklearn.linear_model import Perceptron
import numpy as np 

test_train = np.array([(3,3),(4,3),(1,1)])
test_labels = np.array([1,1,-1])

# 参数
# max_iter 迭代次数
# tol 终止条件
# eta0 学习率
# penalty 正则化项 ’l2‘ or ’l1‘ or ’elasticnet‘
# alpha 正则化系数
perceptron = Perceptron()

perceptron.fit(test_train,test_labels)

# 属性
# coef_  权重,对应w
# intercept_ 对应b
print("w:", perceptron.coef_,
    "b:",perceptron.intercept_)

# 测试模型的预测准确率
train_train = np.array([(3,4),(9,3),(0,1)])
train_labels = np.array([-1,1,-1])
res = perceptron.score(train_train,train_labels)

print("model training score :", res)